/*
 * gwGpio.h
 *
 *  Created on: 2021��6��11��
 *      Author: Administrator
 */

#ifndef SRC_GPIO_GWGPIO_H_
#define SRC_GPIO_GWGPIO_H_

#include "../utility.h"
#include "xgpio.h"

#define GPIO_0_DEVICE_ID        XPAR_GPIO_0_DEVICE_ID
#define GPIO_0_REG_BASEADDR	XPAR_GPIO_0_BASEADDR

#define USER_CHANNEL	1

#define OUT_DIR     1
#define IN_DIR      0

#define XGpio_GetDataDirection(InstancePtr) \
        XGpio_GetDataDirection(InstancePtr, USER_CHANNEL)

#define XGpio_SetDataDirection(InstancePtr, DirectionMask) \
        XGpio_SetDataDirection(InstancePtr, USER_CHANNEL, DirectionMask)

#define XGpio_DiscreteRead(InstancePtr) \
        XGpio_DiscreteRead(InstancePtr, USER_CHANNEL)

#define XGpio_DiscreteWrite(InstancePtr, Data) \
        XGpio_DiscreteWrite(InstancePtr, USER_CHANNEL, Data)

#define XGpio_DiscreteSet(InstancePtr, Mask) \
        XGpio_DiscreteSet(InstancePtr, USER_CHANNEL, Mask)

#define XGpio_DiscreteClear(InstancePtr, Mask) \
        XGpio_DiscreteClear(InstancePtr, USER_CHANNEL, Mask)



/*********************  gpio 0  *********************/

#define I_TX2_SYNC              0x04000000
#define I_TX1_SYNC              0x02000000
#define I_RX_SYNC               0x01000000

#define O_SOFT_RST              0x00800000
#define O_LED1                  0x00400000 // 22
#define O_LED2                  0x00200000
#define O_LED3                  0x00100000

#define I_AD7417_OTI            0x00080000
#define O_IIC_EN_0              0x00040000
#define O_IIC_EN_1              0x00020000 //17
#define I_VPX0_GA0              0x00010000

#define I_VPX0_GA1              0x00008000
#define I_VPX0_GA2              0x00004000
#define I_VPX0_GA3              0x00002000
#define I_VPX0_GA4              0x00001000

#define I_VPX0_GAP              0x00000800
#define O_SW_VCON               0x00000400
#define O_HMC7044_RESET         0x00000200
#define O_HMC7044_SYNC          0x00000100

#define I_HMC7044_PLL1LOCK      0x00000080
#define I_HMC7044_PLL2LOCK      0x00000040
#define I_HMC7044_PHASE         0x00000020
#define O_ADC_PWDN_TO_BUF       0x00000010

#define O_DAC_NRESET            0x00000008
#define I_DAC_NIRQ0             0x00000004
#define I_DAC_NIRQ1             0x00000002
#define I_PG_DONE               0x00000001 // 0



int init_gpio();

void gpio_startup();

int read_gpio(u32 gpio_io);
void set_gpio(u32 gpio_io);
void reset_gpio(u32 gpio_io);

#endif /* SRC_GPIO_GWGPIO_H_ */
